<template>
	<view class="wrapper">
		<head-title showLeftButton="true" :titleText="titleText" statusColor="linear-gradient(to right,#AE33F6,#6673FF)"></head-title>
		<view class="tabCont flex_row">
			<view @click="bindTab(index)" :class="{active:tab==index}" class="tab flex_col" v-for="(item,index) in tabList" :key="index">
				<view>{{item}}</view>
			</view>
		</view>
		<act-list
		 @bindActivity="bindActivity"
		 @tolower="tolower"
		 :windowH="windowH"
		 :list="list"
		 :titleText="titleText"
		 :nolist="nolist"
		 :loading="loading"
		 :loadTxt="loadTxt"
		 
		 ></act-list>
	</view>
</template>
<script>
	import common from "../../common/network.js";
	import headTitle from "../../components/headTitle.vue";
	import actList from "../../components/actList.vue";
	var session = '',cid='',page=1,fullpage=1;
	export default {
		components:{actList,headTitle},
		data(){
			return{
				windowH:0,
				titleText:'',list:[],loading:false,loadTxt:'正在加载...',
				tabList:['离我最近','最新发布'],tab:0,nolist:false,
			}
		},
		onLoad:function(options){
			var that = this;
			var title = options.title;
			// console.log(options);
			common.network.getHeight(function(h,w){
				that.windowH = h - w/750 * 250;
				page = 1;
			})
			if(title!=undefined){
				this.titleText = title + '邀约';
				cid = options.cid;
				session = options.session;
				this.getList();
			}
		},
		methods:{
			getList:function(shows){
				var that = this;
				var num = that.tab;
				var $data = {
					'type':'zac_ac_list',
					'session':session,
					'h_class':cid,
					'order_style':num+1,
					'page':page
				};
				common.network.request($data,function(res){
					fullpage = res.pageData.pagecount;
					// console.log(res);
					if(shows){
						that.list = res.list;
					}else{
						that.list = (that.list).concat(res.list);
					}
					that.loading = false;
					if((that.list).concat(res.list)==''){
						that.nolist=true;
					}else{
						that.nolist = false;
					}
				})
			},
			bindActivity:function(id){
				uni.navigateTo({
					url:'/pagesA/actDetail/actDetail?session='+session+'&actid='+id
				})
			},
			bindTab:function(index){
				this.tab = index;
				this.getList('shows');
			},
			tolower:function(){
				console.log('到底了')
				this.loading = true;
				if(page>=fullpage){
					this.loadTxt = "我是有底线的";
					return false;
				}else{
					this.loadTxt = "正在加载...";
					page ++;
					this.getList();
				}
			},
		}
	}
</script>

<style scoped>
	.tabCont{
		font-size: 30px;
		margin-bottom: 20px;
		box-shadow: 0 1px 10px #e1e1e1;
		width: 100%;
	}
	.tab{
		width: 50%;
		height: 88px;
		justify-content: center;
		position: relative;
		transition: all 0.4s;
	}
	.tab:after{
		content: '';
		height: 6px;
		width: 0;
		background: transparent;
		position: absolute;
		bottom: 0;
		left: 50%;
		transition: all 0.4s;
	}
	.tab.active{
		color: #676BF3;
	}
	.tab.active:after{
		background: #676BF3;
		width: 100%;
		left: 0;
	}
	.tab view{
		width: 100%;
		position: relative;
		text-align: center;
	}
	.tab view:after{
		content: '';
		height: 100%;
		width: 1px;
		background: #f1f1f1;
		position: absolute;
		top: 0;
		right: 0;
	}
</style>
